import Vue from 'vue'
import VueRouter from 'vue-router'
// 登录
import Login from '../views/Login'
// 首页
import Layout from '../views/Layout'
import Home from '../views/Layout/Home'
import User from '../views/Layout/User'
import Search from '../views/Search'
import SearchResultList from '../views/Search/SearchResult.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/layout',
    component: Layout,
    redirect: '/layout/home',
    children: [
      {
        path: 'home',
        component: Home
      },
      {
        path: 'user',
        component: User
      }
    ]
  },
  { // 搜索页
    path: '/search',
    component: Search
  },
  { // 搜索结果页
    path: '/search/:keyword', // 动态路由
    component: SearchResultList
  }
]

const router = new VueRouter({
  routes
})

export default router
